#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int cnt[1000];
void solve()
{
	memset(cnt,-1,sizeof(cnt));
    int n;
    cin>>n;
    string s;
    cin>>s;
    bool flag=1;
    for(int i=0;i<n;i++){
        if(cnt[s[i]]==-1){
            cnt[s[i]]=i;
        }
        else{
            if((i-cnt[s[i]])%2==1)
                flag=0;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

}

int main()
{
	close();
	int T; cin>>T;
	while (T--) solve();
	return 0;
}

